package com.kuaiditu.assistant.ui.profile;

import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.kuaiditu.assistant.R;
import com.kuaiditu.assistant.base.BaseActivity;
import com.kuaiditu.assistant.common.Constants;
import com.kuaiditu.assistant.entity.AssistantUser;
import com.kuaiditu.assistant.event.NeedReloadEvent;
import com.kuaiditu.assistant.module.storage.AssistantUserStorage;
import com.kuaiditu.assistant.ui.balance.BalanceActivity;
import com.kuaiditu.assistant.ui.balance.FillAliCodeActivity;
import com.kuaiditu.assistant.view.topbar.TopBar;

import org.greenrobot.eventbus.EventBus;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;


@Route(path = ProfileActivity.PATH, extras = Constants.NEED_LOGIN_EXTRA)
public class ProfileActivity extends BaseActivity {

    @BindView(R.id.top_bar)
    TopBar topBar;
    @BindView(R.id.ll_account)
    LinearLayout llAccount;
    @BindView(R.id.ll_ali_account)
    LinearLayout llAliAccount;
    @BindView(R.id.ll_balance)
    LinearLayout llBalance;
    @BindView(R.id.ll_task)
    LinearLayout llTask;
    @BindView(R.id.ll_aboutus)
    LinearLayout llAboutus;
    @BindView(R.id.ll_setting)
    LinearLayout llSetting;


    AssistantUser mAssistantUser;
    @BindView(R.id.img_header)
    ImageView imgHeader;
    @BindView(R.id.tv_account)
    TextView tvAccount;

    @BindView(R.id.btn_logout)
    Button btnLogout;

    AssistantUserStorage mAssistantUserStorage;



    public static final String PATH = "/user/profile";

    @Override
    public int initContentView() {
        return R.layout.activity_profile;
    }

    @Override
    public void initInjector() {
        mAssistantUserStorage = getApplicationComponent().getUserStorage();
        mAssistantUser = mAssistantUserStorage.getUser();
    }

    @Override
    public void initUiAndListener() {
        ButterKnife.bind(this);
        topBar.bind(this, true);
        tvAccount.setText(mAssistantUser.getCourier_mobile());


    }


    @OnClick(R.id.ll_account)
    public void onLlAccountClicked() {
    }

    @OnClick(R.id.ll_ali_account)
    public void onLlAliAccountClicked() {
        ARouter.getInstance().build(FillAliCodeActivity.PATH).navigation();

    }

    @OnClick(R.id.ll_balance)
    public void onLlBalanceClicked() {
        ARouter.getInstance().build(BalanceActivity.PATH).navigation();
    }

    @OnClick(R.id.ll_task)
    public void onLlTaskClicked() {
    }

    @OnClick(R.id.ll_aboutus)
    public void onLlAboutusClicked() {
    }

    @OnClick(R.id.ll_setting)
    public void onLlSettingClicked() {
    }


    @OnClick(R.id.btn_logout)
    public void onLogoutClick() {
        mAssistantUserStorage.logout();
        EventBus.getDefault().post(new NeedReloadEvent());
        finish();
    }

}
